import { pubRequire } from '@utils/public'
const baseUrl = '/integrals/agreements'
const ruleUrl = '/integrals/rules'
// 积分协议列表
export function getIntegralsList(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}`, params, callBack, errBack)
}
// 积分协议添加
export function addIntegral(params, callBack, errBack) {
  return pubRequire('post', `${baseUrl}`, params, callBack, errBack)
}
// 积分规则修改
export function editIntegral(params, agreementId, callBack, errBack) {
  return pubRequire(
    'put',
    `${baseUrl}/${agreementId}`,
    params,
    callBack,
    errBack
  )
}
// 积分协议详情
export function getDetail(agreementId, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/${agreementId}`, '', callBack, errBack)
}
// 积分规则删除
export function delIntegral(agreementId, callBack, errBack) {
  return pubRequire(
    'delete',
    `${baseUrl}/${agreementId}`,
    '',
    callBack,
    errBack
  )
}
// 积分规则查询
export function getRule(callBack, errBack) {
  return pubRequire('get', `${ruleUrl}`, '', callBack, errBack)
}
// 积分规则修改
export function editRule(params, callBack, errBack) {
  return pubRequire('put', `${ruleUrl}`, params, callBack, errBack)
}

//修改鲜花兑换积分比例设置
export function editFlowerRule(params, callBack, errBack) {
  return pubRequire('put', `${ruleUrl}/flowers-ratio`, params, callBack, errBack)
}

